
$(function () {
  new VConsole();

  // var options = {
  //   hls: {
  //     withCredentials: true
  //   }
  // };
  console.log('navigator.userAgent')
  console.log(navigator.userAgent)
  if(/UIWebView Device/i.test(navigator.userAgent)) {
    var video_html = '<video controls width="100%" height="100%" id="iosVideo" poster="http://avatar.wpn.itlukai.com/poster.jpg"><source src='+ $(".player-video").attr("src") +' type="application/x-mpegURL"></video><button class="vjs-big-play-button" type="button" aria-live="polite" title="Play Video" aria-disabled="false"><span aria-hidden="true" class="vjs-icon-placeholder"></span><span class="vjs-control-text">Play Video</span></button>'
    $('.player-video').html(video_html)
    $('.player-video').on('click', function () {
      $(this).find('video').get(0).play()
    })
  } else {
    videojs('my-player', {
      // techOrder: ["html5", "flash"],
      sources: [{
        src: $(".player-video").attr("src"),
        type: "application/x-mpegURL"
      }],
      playbackRates: [0.5, 1, 1.2, 1.5, 2],
    }, function () {
      $(".player-video").removeAttr("src")
    })
  }

  $('video').on('contextmenu', function(){
    return false
  })

  var hidden_toolbar = window.localStorage.getItem('hidden_toolbar') || ''
  if (hidden_toolbar) {
    $('.player-toolbar-box').addClass('hidden_toolbar')
  }

  $('.toggle-btn').on('click', function () {
    $('.player-toolbar-box').toggleClass('hidden_toolbar')
    hidden_toolbar = $('.player-toolbar-box').hasClass('hidden_toolbar') || ''
    window.localStorage.setItem('hidden_toolbar', hidden_toolbar)
  })

  function resetVideo() {
    if (parseInt($(window).width()) <= 1000) {
      $('.player-layout').addClass('vertical')
    } else {
      $('.player-layout').removeClass('vertical')
    }
    $('.player-layout').removeClass('vis-hd')
  }

  resetVideo()
  $(window).on('resize', function () {
    resetVideo()
  })

  $('.video-relatives-nav a').on('click', function () {
    if ($(this).hasClass('share-btn')) {
      return
    }

    var _index = $(this).index()
    $(this).addClass('on').siblings().removeClass('on')
    $('.video-relatives-con .relatives-box').eq(_index).show().siblings().hide()
  })

  $('.submit-btn').click(function () {
    
  })
})






